/*
 * Copyright (C) 2021 The Chinese Software International Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.zyyoona7.wheelpicker.utils;

import java.security.SecureRandom;

/**
 * 描述
 *
 * @author wjt
 * @since 2021-04-22
 */
public final class RandomUtil {
    private RandomUtil() {
    }

    /**
     * 随机数生成
     *
     * @return 随机数
     */
    public static int nextInt() {
        return new SecureRandomTest().getRandom();
    }

    /**
     * SecureRandom
     *
     * @since 2021-04-22
     */
    public static class SecureRandomTest {
        private final SecureRandom ran;

        /**
         * 初始化 SecureRandom
         */
        public SecureRandomTest() {
            ran = new SecureRandom();
        }

        /**
         * 获取随机数
         *
         * @param seed
         * @return 随机数
         */
        public int getRandom(int seed) {
            return ran.nextInt(seed);
        }

        /**
         * getRandom
         *
         * @return int
         */
        public int getRandom() {
            return ran.nextInt();
        }
    }
}
